package com.cx.atguigu.controller;

import dev.langchain4j.model.chat.ChatModel;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Description:
 *
 * @Author atguigu
 * @Create 2025/8/25 20:25
 * @Version 1.0
 */
@RestController
@Slf4j
public class HelloLangChain4jController {
    @Resource
    private ChatModel chatModelQwen;
    // http://localhost:9001/langchain4j/hello?prompt=如何学习java
    @GetMapping("/langchain4j/hello")
    public String hello(@RequestParam(value = "prompt", defaultValue = "你好,你是谁") String prompt) {
        String result = chatModelQwen.chat(prompt);
        System.out.println("通过langchain4j调用千问plus大模型返回结果: +\n" + result);
        return result;
    }
}
